﻿using System;
using System.Collections.Generic;
using ContractManager.Entity;
using Speed.Data;

namespace ContractManager.BLL.Business
{
    public static class ClsCitys
    {
        public static List<Citys> SelectAll()
        {
            using (var db = Sys.NewDb())
            {
                return Data.Base.Citys.Select(db);
            }
            
        }

        public static void Insert(Citys capital)
        {
            using (var db = Sys.NewDb())
            {
                db.Insert<Citys>(capital, EnumSaveMode.Requery);
            }
            
        }

        public static void Update(Citys capital)
        {
            using (var db = Sys.NewDb())
            {
                db.Update<Citys>(capital);
            }
            
        }

        public static Citys SelectByPk(Int32 cityId)
        {
            using (var db = Sys.NewDb())
            {
                return db.SelectSingle<Citys>(string.Format("CityId={0}", cityId));
            }
            
        }

        public static Citys SelectByCode(string cityCode)
        {
            using (var db = Sys.NewDb())
            {
                return db.SelectSingle<Citys>(string.Format("CityCode='{0}'", cityCode));
            }
            
        }

        public static int DeleteByPk(Int32 cityId)
        {
            using (var db = Sys.NewDb())
            {
                return db.Delete<Citys>(string.Format("CityId={0}", cityId));
            }
            
        }
    }
}